/*
 * @(#)TablesConfigModify.java   1.0  2021年11月24日
 * 
 * Copyright (c)	2014-2020. All Rights Reserved.	GuangZhou hhmk Technology Company LTD.
 */
package com.swift.dts.service;

import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.swift.core.auth.Login;
import com.swift.core.model.ServiceRequest;
import com.swift.core.model.data.DataModel;
import com.swift.core.model.data.MapDataModel;
import com.swift.core.service.SynInterface;
import com.swift.dts.loadconfig.FileTablesConfig;
import com.swift.util.type.TypeUtil;

/**
 * 添加说明 
 * @author zhengjiajin
 * @version 1.0 2021年11月24日
 */
@Service("tablesConfigModify")
@Login
public class TablesConfigModify implements SynInterface {

    @Autowired
    private FileTablesConfig fileTablesConfig;
    
    /** 
     * @see com.swift.core.service.SynInterface#doService(com.swift.core.model.ServiceRequest)
     */
    @SuppressWarnings({ "rawtypes", "unchecked" })
    @Override
    public DataModel doService(ServiceRequest req) {
        String synTable = req.getData().getString("synTable");
        String blackFilter = req.getData().getString("blackFilter");
        String onlyDdlFilter = req.getData().getString("onlyDdlFilter");
        String tableNameChange = req.getData().getString("tableNameChange");
        DataModel res = new MapDataModel();
        Map map = fileTablesConfig.loadMap();
        map.put("synTable", TypeUtil.toString(synTable, "*").split("\n"));
        map.put("blackFilter", TypeUtil.toString(blackFilter, "").split("\n"));
        map.put("onlyDdlFilter", TypeUtil.toString(onlyDdlFilter, "").split("\n"));
        map.put("tableNameChange", tableNameChange);
        fileTablesConfig.saveMap(map);
        return res;
    }

}
